package src.threadpool;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ScheduledThreadPoolTest {
    public static void main(String[] args) {
        // 创建一个ScheduledThreadPoolExecutor，核心线程数为2
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);

        // 提交一个定时任务，延迟5秒执行
        executor.schedule(new Task(), 5, TimeUnit.SECONDS);

        // 提交一个周期性任务，每隔3秒执行一次
        executor.scheduleAtFixedRate(new Task(), 1, 3, TimeUnit.SECONDS);
    }
}
